package com.tushare.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tushare.entity.MarginDetail;
import com.tushare.mapper.MarginDetailMapper;
import com.tushare.service.IMarginDetailService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-03-08
 */
@Service
public class MarginDetailServiceImpl extends ServiceImpl<MarginDetailMapper, MarginDetail> implements IMarginDetailService {

    @Override
    public MarginDetail getLastMarginDetail() {
        return getBaseMapper().getLastMarginDetail();
    }

    @Override
    public List<MarginDetail> getMarginDetailListByTsCode(String ts_code, int trade_date) {
        return getBaseMapper().getMarginDetailListByTsCode(ts_code, trade_date);
    }

    @Override
    public List<MarginDetail> getTopMarginDetailList(String ts_code, int limit) {
        return getBaseMapper().getTopMarginDetailList(ts_code, limit);
    }

    @Override
    public boolean saveOrUpdateBatch(List<MarginDetail> list) {
        if (list == null) {
            return false;
        }
        if (list.size() == 0) {
            return true;
        }
        return getBaseMapper().saveOrUpdateBatch(list);
    }

    @Override
    public boolean deleteAllMarginDetail() {
        return getBaseMapper().deleteAllMarginDetail();
    }
}
